package com.xiaoKe.zhonghzu.global.okhttp;

import android.content.Context;
import android.os.Environment;

import com.xiaoKe.zhonghzu.global.tool.AppConstant;
import com.xiaoKe.zhonghzu.global.tool.Logger;
import com.xiaoKe.zhonghzu.global.tool.SPUtils;
import com.xiaoKe.zhonghzu.global.tool.ToastUtils;

import java.io.File;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ProjectName : yg119
 * @Author : Shijingna
 * @Time : 2024/7/12 17:13
 * @Description : 文件描述
 */
@NoArgsConstructor
@Data
public class AppManager {

    private static AppManager instance = new AppManager();
    private static RequestParams requestParams = new RequestParams();
    public void init(Context context) {
        SPUtils.init(context);//初始化SharePreference
        Logger.init(AppConstant.DEBUG_TAG, AppConstant.IS_DEBUG);//初始化sout
        ToastUtils.init(context);//初始化toast
        initDir(context);


    }

    public static RequestParams getRequestParams() {
        return requestParams;
    }

    public static AppManager getInstance() {
        return instance;
    }

    private void initDir(Context context) {
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            //sd卡存在
        } else {
            //sd卡不存在
        }
        AppConstant.CACHE_FILE_PATH = context.getExternalFilesDir(null).getAbsolutePath() + "/kcxd/";
        try {
            File file = new File(AppConstant.CACHE_FILE_PATH);
            if (!file.exists()) {
                boolean mkdirs = file.mkdirs();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
